package com.interview.one.common;

import lombok.Data;

/**
 * Created by hzllb on 2019/7/9.
 */
@Data
public class CommonRes {

    private short code;


    //若code = 1时，表明对应的返回的json类数据
    //若status=fail时，则data内将使用通用的错误码对应的格式
    private Object data;

    private String message;

    //定义一个通用的创建返回对象的方法
    public static CommonRes create(Object result){
        return CommonRes.create(result,"");
    }


    public static CommonRes create(Object result,String message){
        CommonRes commonRes = new CommonRes();
        commonRes.setCode((short)1);
        commonRes.setData(result);
        commonRes.setMessage(message);
        return commonRes;
    }


}
